package hw04.grammar.productions;

import hw04.grammar.Executable;
import hw04.grammar.terminals.EvalMode;
import hw04.grammar.terminals.Trace;

import java.util.LinkedList;
import java.util.List;

public class Command implements Executable {
	
	private List<Executable> value = new LinkedList<Executable>();
	
	public Command(Fact f) {
		value.add(f);
	}
	
	public Command(Rule r) {
		value.add(r);
	}
	
	public Command(Trace t) {
		value.add(t);
	}
	
	public Command(Command c1, Command c2) {
		value.addAll(c1.getValue());
		value.addAll(c2.getValue());
	}
	
	public Command(EvalMode em) {
		value.add(em);
	}
	
	public List<Executable> getValue() {
		return value;
	}
	
	@Override
	public String toString() {
		return getClass().getSimpleName() + ":" + getValue().toString();
	}

	@Override
	public void execute() {
		for(Executable c : getValue()) {
			c.execute();
		}
	}

}
